package day03;

import util.音频;

import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class PianoX extends Frame {
    public  void start(){
        addKeyListener(new Key());
        setSize(800,500);
        setVisible(true);
    }
    //keyCode
   class Key extends KeyAdapter{
        @Override
        public void keyPressed(KeyEvent e) {
            int k = e.getKeyCode();
            if(k == KeyEvent.VK_LEFT){
                new 音频("/架子鼓/底鼓.mp3").start();
            }
            if(k == KeyEvent.VK_RIGHT){
                new 音频("/架子鼓/军鼓.mp3").start();
            }
            if(k == KeyEvent.VK_DOWN){
                new 音频("/架子鼓/镲.mp3").start();
            }
            if(k == KeyEvent.VK_UP){
                new 音频("/架子鼓/敲锣.mp3").start();
            }
            if (k == KeyEvent.VK_1) {
                new 音频("/music/h1.mp3").start();
                new 音频("/music/h3.mp3").start();
                new 音频("/music/h5.mp3").start();
            }
            if (k == KeyEvent.VK_2) {
                new 音频("/music/h2.mp3").start();
                new 音频("/music/h4.mp3").start();
                new 音频("/music/h6.mp3").start();
            }
            if (k == KeyEvent.VK_3) {
                new 音频("/music/h3.mp3").start();
                new 音频("/music/h5.mp3").start();
                new 音频("/music/h7.mp3").start();
            }
            if (k == KeyEvent.VK_4) {
                new 音频("/music/h4.mp3").start();
                new 音频("/music/h6.mp3").start();
                new 音频("/music/h1.mp3").start();
            }
            if (k == KeyEvent.VK_5) {
                new 音频("/music/h5.mp3").start();
                new 音频("/music/h7.mp3").start();
                new 音频("/music/h2.mp3").start();
            }
            if (k == KeyEvent.VK_6) {
                new 音频("/music/h6.mp3").start();
                new 音频("/music/h1.mp3").start();
                new 音频("/music/h3.mp3").start();
            }
        }
    }


    @Override
    public void paint(Graphics g) {
        g.setFont(new Font("aa",1,22));
        g.drawString("C  D  E  F  G  A   B ",10,60);
        g.drawString("1   2   3  4  5   6   7 ",10,100);
    }

    public static void main(String[] args) {
        new PianoX().start();
    }
}
